using System;
using System.Collections.Generic;
using System.Text;

namespace SiteGrabber
{


    ///// <summary>
    ///// Task configuration class
    ///// </summary>
    //class TrackerItem
    //{
    //    /// <summary>
    //    /// Name of task
    //    /// </summary>
    //    public string Name = "";

    //    /// <summary>
    //    /// URI of site to check
    //    /// </summary>
    //    public Uri SiteUri = null;

    //    /// <summary>
    //    /// Interval between requests in seconds
    //    /// </summary>
    //    public int FrequencyS = 60 * 1;

    //    /// <summary>
    //    /// Text to find in downloaded page. Normally text in HTML title tag
    //    /// </summary>
    //    public string TextInPage = "Xxxx-no-such-text-in-this-fucking-page-xxxX";

    //    /// <summary>
    //    /// Last time we check site
    //    /// </summary>
    //    public DateTime LastCheck = DateTime.MaxValue;

    //    /// <summary>
    //    /// How many seconds to display popup on OK. 0 - means no popup
    //    /// </summary>
    //    public int PopupOkS = 0;

    //    /// <summary>
    //    /// How many seconds to display popup on error. 0 - means no popup
    //    /// </summary>
    //    public int PopupFailS = 10;

    //    /// <summary>
    //    /// HTTP response from site
    //    /// </summary>
    //    public int ResponseCode = 666;

    //    public int ReceivedBytes = 0;

    //    public override string ToString()
    //    {
    //        StringBuilder sb = new StringBuilder();

    //        sb.AppendFormat("{0,-24}{1}", "Name:", Name);
    //        sb.AppendLine();
    //        sb.AppendFormat("{0,-24}{1}", "Uri:", SiteUri.ToString());
    //        sb.AppendLine();
    //        sb.AppendFormat("{0,-24}{1}", "Search text:", TextInPage);
    //        sb.AppendLine();
    //        sb.AppendFormat("{0,-24}{1}", "Frequency (s):", FrequencyS);
    //        sb.AppendLine();
    //        sb.AppendFormat("{0,-24}{1}", "Fail popup (s):", PopupFailS);
    //        sb.AppendLine();
    //        sb.AppendFormat("{0,-24}{1}", "Ok popup (s):", PopupOkS);

    //        return sb.ToString();
    //    }

    //    /// <summary>
    //    /// Searches configured tracker tasks and returns TrackerItem if found
    //    /// </summary>
    //    /// <param name="trackerName">Name of task to search</param>
    //    public static TrackerItem GetByName(string trackerName)
    //    {
    //        for( int i = 0; (Settings.TrackerItems != null) && (i < Settings.TrackerItems.Length); i++ )
    //        {
    //            if( Settings.TrackerItems[i].Name == trackerName )
    //                return Settings.TrackerItems[i];
    //        }

    //        return null;
    //    }
    //}


    /// <summary>
    /// Class to display context menu
    /// </summary>
    class MyMenu
    {
        /// <summary>
        /// Contains names of menu items
        /// </summary>
        protected static string[] m_arNames = null;

        /// <summary>
        /// How many menu item
        /// </summary>
        public const int Size = 5;

        /// <summary>
        /// Position in menu list
        /// </summary>
        public class Position
        {
            public const int Start = 0;
            public const int Stop = 1;
            //public const int LastErrors = 2;
            public const int Version = 2;
            public const int Reload = 3;
            public const int Exit = 4;
        }

        /// <summary>
        /// Returns name of item by position
        /// </summary>
        /// <param name="pos">Position in menu. Should be [0; Size)</param>
        /// <returns></returns>
        public static string ToName(int pos)
        {
            // Like constructor - creates array on the first use
            if( m_arNames == null )
            {
                m_arNames = new string[Size];
                m_arNames[Position.Start] = "Start";
                m_arNames[Position.Stop] = "Stop";
                //m_arNames[Position.LastErrors] = "Last errors";
                m_arNames[Position.Version] = "Version";
                m_arNames[Position.Reload] = "Reload settings";
                m_arNames[Position.Exit] = "Exit";
            }

            if( (pos >= 0) && (pos < Size) )
            {
                return m_arNames[pos];
            }

            return pos.ToString();
        }

    }
}
